home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.02 Feb 91 / xserial source ƒ / xparse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-24  |  762 b   |  38 lines  |  [TEXT/MSWD]

  1.  
  2. #include    <stdarg.h>
  3. #include    <string.h>
  4. #include     "xcmd.h"
  5.  
  6. /* Copies supplied parameters (each comes in as a string
  7.  * to the supplied parameter block and sets the number of
  8.  * parameters field approriately. Note that this routine
  9.  * can handle a variable number of arguments. It uses the
  10.  * macros (in stdarg.h) supplied with Think C to manage
  11.  * the variable number of arguments correctly. The last
  12.  * argument must be a null string ("").
  13.  */
  14.  
  15. #ifdef XTEST
  16.  
  17. void    xpars(XCmdBlock *pb,...)
  18. {
  19.     va_list        xp;
  20.     char        *s;
  21.     short        i;
  22.     
  23.     va_start(xp,pb);
  24.     s = va_arg(xp,char *);
  25.     i = 0;
  26.     while (*s && i <= 15) /* can have a maximum of 16 arguments */
  27.         {
  28.         strcpy(*(pb->params[i]),s);
  29.         i++;
  30.         s = va_arg(xp,char *);
  31.         }
  32.     pb->paramCount = i;
  33.     va_end(xp);
  34. }
  35. #endif
  36.  
  37.  
  38.